home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / os2 / adaptor.zip / ADAPT.ZIP / adaptor / dalib / pvm3 / mnode.c < prev    next >
Text File  |  1993-11-29  |  4KB  |  112 lines

  1. /*******************************************************************
  2. *                                                                  *
  3. *  Author      : Dr. Thomas Brandes, GMD, I1.HR                    *
  4. *  Copyright   : GMD St. Augustin, Germany                         *
  5. *  Date        : Feb 92                                            *
  6. *  Last Update : Feb 93                                            *
  7. *                                                                  *
  8. *  This Module is part of the DALIB                                *
  9. *                                                                  *
  10. *  MAIN OF NODE PROGRAM for PVM (Version 3.0)                      *
  11. *                                                                  *
  12. *  MODULE : mnode.c                                                *
  13. *                                                                  *
  14. *  Function: Realization of System Dependent Operations            *
  15. *                                                                  *
  16. *  - is spawned by the host process                                *
  17. *  - enrolls node in PVM                                           *
  18. *  - calls nodemodule ()                                           *
  19. *                                                                  *
  20. *******************************************************************/
  21.  
  22. /*******************************************************************
  23. *                                                                  *
  24. *  Interface to Adaptor:                                           *
  25. *                                                                  *
  26. *    dalib_pid_   ()                                               *
  27. *    dalib_nproc_ ()                                               *
  28. *                                                                  *
  29. *******************************************************************/
  30.  
  31. #include <stdio.h>
  32. #include <string.h>
  33. #include "system.h"
  34. #include "pvm3.h"
  35.  
  36. #define INIT_MSGID  9999
  37.  
  38. int NP;          /* number of node processes */
  39. int my_id;       /* number of my process: 0 (host), 1 .. NP */
  40.  
  41. #ifdef IBM
  42. void nodemodule ();
  43. #else
  44. void nodemodule_ ();
  45. #endif
  46.  
  47. void MAIN__ ()
  48.  
  49. { int i;
  50.   int waitid;
  51.   int status;
  52.   int mytid;
  53.  
  54.   unsigned long startt;   /* start timer value */
  55.   int htrace_flag;
  56.  
  57.   target_model = 0;       /* with host */
  58.  
  59.   /* enroll in PVM */
  60.  
  61.   mytid = pvm_mytid();
  62.  
  63.   /* recv initial message */
  64.  
  65.   pvm_recv (-1, INIT_MSGID);
  66.   pvm_upkbyte (&NP, sizeof(int), 1);
  67.   pvm_upkbyte (tids, (NP+1)*sizeof(int), 1);
  68.  
  69.   /* try to find my_id */
  70.  
  71.   for (i=1; i<=NP ; i++)
  72.      if (mytid == tids[i]) { my_id = i; break; }
  73.  
  74.   /* tell host that I am ready */
  75.  
  76.   pvm_initsend (PvmDataRaw);
  77.   pvm_pkbyte (&my_id, sizeof(int), 1);
  78.   pvm_send (tids[0], INIT_MSGID -1);
  79.  
  80.   /* definition of the process control block */
  81.  
  82.   pcb.i       = my_id;
  83.   pcb.p       = NP;
  84.  
  85.   random_block_init ();
  86.   dalib_init_walltime ();
  87.  
  88.   /* initialization of tracing */
  89.  
  90. #ifdef IBM
  91.   nodemodule ();
  92. #else
  93.   nodemodule_ ();
  94. #endif
  95.  
  96.   pvm_exit ();   /* exit PVM */
  97. }
  98.  
  99. /*******************************************************************
  100. *                                                                  *
  101. *  number and ids of processes                                     *
  102. *                                                                  *
  103. *******************************************************************/
  104.  
  105. int dalib_pid_ ()
  106. {
  107.    return (my_id);
  108. }
  109.  
  110. int dalib_nproc_ ()
  111. { return (NP); }
  112.